package org.ikastola

import java.util.Date;

import ikastola.Constants

class Fee {

	String name
	Double value //es la suma de los values de los feeDetails 
	String description
	String period
	Integer dueday //dia del mes en que el vence
	Integer deleted
	Date classCreated
	Date classUpdated
	List feeDetails
	
	static hasMany = [feeDetails: FeeDetail]
	
	static mapping = {
		feeDetails lazy: false
	}
		
	static constraints = {
		name blank:false
		value blank:false
		description blank:false
		period inList: [Constants.FEE_PERIOD_MONTH, Constants.FEE_PERIOD_ANNUAL] //1: mensual, 2: anual
		dueday inList: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]
		deleted blank: false
		classCreated nullable: true
		classUpdated nullable: true
		feeDetails nullable: true
	}
	
	def static list() {
		return findAllByDeleted(Constants.NOT_DELETED)
	}
}
